home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / libx11 / include / x11 / xpm.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  13KB  |  402 lines

  1. /* Copyright 1989-94 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * xpm.h:                                                                      *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Include file                                                               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #ifndef XPM_h
  12. #define XPM_h
  13.  
  14. /*
  15.  * first some identification numbers:
  16.  * the following revision numbers is determined with the following rule:
  17.  * SO Major number = LIB minor version number.
  18.  * SO Minor number = LIB sub-minor version number.
  19.  * e.g: Xpm version 3.2f
  20.  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
  21.  *      thus we have XpmVersion = 2 and XpmRevision = 6
  22.  *      which gives  SOXPMLIBREV = 2.6
  23.  *
  24.  * Then the XpmIncludeVersion number is built with the following rule:
  25.  * (XpmFormat*100 + XpmVersion)*100 + XpmRevision
  26.  */
  27. #define XpmFormat 3
  28. #define XpmVersion 4
  29. #define XpmRevision 1
  30.  
  31. #define XpmIncludeVersion 30401
  32.  
  33. #ifndef XPM_NUMBERS
  34.  
  35. #ifdef VMS
  36. #include "decw$include:Xlib.h"
  37. #include "decw$include:Xutil.h"
  38. #else
  39. #include <X11/Xlib.h>
  40. #include <X11/Xutil.h>
  41. #endif
  42.  
  43. /* let's define Pixel if it is not done yet */
  44. #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
  45. typedef unsigned long Pixel;        /* Index into colormap */
  46. #define PIXEL_ALREADY_TYPEDEFED
  47. #endif
  48.  
  49. /* Return ErrorStatus codes:
  50.  * null     if full success
  51.  * positive if partial success
  52.  * negative if failure
  53.  */
  54.  
  55. #define XpmColorError    1
  56. #define XpmSuccess       0
  57. #define XpmOpenFailed   -1
  58. #define XpmFileInvalid  -2
  59. #define XpmNoMemory     -3
  60. #define XpmColorFailed  -4
  61.  
  62. /* the following should help people wanting to use their own functions */
  63. #define XpmFree(ptr) free(ptr)
  64.  
  65. typedef struct {
  66.     char *name;                /* Symbolic color name */
  67.     char *value;            /* Color value */
  68.     Pixel pixel;            /* Color pixel */
  69. }      XpmColorSymbol;
  70.  
  71. typedef struct {
  72.     char *name;                /* name of the extension */
  73.     unsigned int nlines;        /* number of lines in this extension */
  74.     char **lines;            /* pointer to the extension array of
  75.                      * strings */
  76. }      XpmExtension;
  77.  
  78. typedef struct {
  79.     char *string;        /* characters string */
  80.     char *symbolic;        /* symbolic name */
  81.     char *m_color;        /* monochrom default */
  82.     char *g4_color;        /* 4 level grayscale default */
  83.     char *g_color;        /* other level grayscale default */
  84.     char *c_color;        /* color default */
  85. }      XpmColor;
  86.  
  87. typedef struct {
  88.     unsigned int width;        /* image width */
  89.     unsigned int height;    /* image height */
  90.     unsigned int cpp;        /* number of characters per pixel */
  91.     unsigned int ncolors;    /* number of colors */
  92.     XpmColor *colorTable;    /* list of related colors */
  93.     unsigned int *data;        /* image data */
  94. }      XpmImage;
  95.  
  96. typedef struct {
  97.     unsigned long valuemask;    /* Specifies which attributes are defined */
  98.     char *hints_cmt;        /* Comment of the hints section */
  99.     char *colors_cmt;        /* Comment of the colors section */
  100.     char *pixels_cmt;        /* Comment of the pixels section */
  101.     unsigned int x_hotspot;    /* Returns the x hotspot's coordinate */
  102.     unsigned int y_hotspot;    /* Returns the y hotspot's coordinate */
  103.     unsigned int nextensions;    /* number of extensions */
  104.     XpmExtension *extensions;    /* pointer to array of extensions */
  105. }      XpmInfo;
  106.  
  107. typedef struct {
  108.     unsigned long valuemask;        /* Specifies which attributes are
  109.                      * defined */
  110.  
  111.     Visual *visual;            /* Specifies the visual to use */
  112.     Colormap colormap;            /* Specifies the colormap to use */
  113.     unsigned int depth;            /* Specifies the depth */
  114.     unsigned int width;            /* Returns the width of the created
  115.                      * pixmap */
  116.     unsigned int height;        /* Returns the height of the created
  117.                      * pixmap */
  118.     unsigned int x_hotspot;        /* Returns the x hotspot's
  119.                      * coordinate */
  120.     unsigned int y_hotspot;        /* Returns the y hotspot's
  121.                      * coordinate */
  122.     unsigned int cpp;            /* Specifies the number of char per
  123.                      * pixel */
  124.     Pixel *pixels;            /* List of used color pixels */
  125.     unsigned int npixels;        /* Number of pixels */
  126.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  127.                      * override */
  128.     unsigned int numsymbols;        /* Number of symbols */
  129.     char *rgb_fname;            /* RGB text file name */
  130.     unsigned int nextensions;        /* number of extensions */
  131.     XpmExtension *extensions;        /* pointer to array of extensions */
  132.  
  133.     unsigned int ncolors;               /* Number of colors */
  134.     XpmColor *colorTable;               /* Color table pointer */
  135. /* 3.2 backward compatibility code */
  136.     char *hints_cmt;                    /* Comment of the hints section */
  137.     char *colors_cmt;                   /* Comment of the colors section */
  138.     char *pixels_cmt;                   /* Comment of the pixels section */
  139. /* end 3.2 bc */
  140.     unsigned int mask_pixel;            /* Transparent pixel's color table
  141.                                          * index */
  142.  
  143.     /* Color Allocation Directives */
  144.     unsigned int exactColors;        /* Only use exact colors for visual */
  145.     unsigned int closeness;        /* Allowable RGB deviation */
  146.     unsigned int red_closeness;        /* Allowable red deviation */
  147.     unsigned int green_closeness;    /* Allowable green deviation */
  148.     unsigned int blue_closeness;    /* Allowable blue deviation */
  149.     int color_key;            /* Use colors from this color set */
  150.  
  151. }      XpmAttributes;
  152.  
  153. /* XpmAttributes value masks bits */
  154. #define XpmVisual       (1L<<0)
  155. #define XpmColormap       (1L<<1)
  156. #define XpmDepth       (1L<<2)
  157. #define XpmSize           (1L<<3)    /* width & height */
  158. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  159. #define XpmCharsPerPixel   (1L<<5)
  160. #define XpmColorSymbols       (1L<<6)
  161. #define XpmRgbFilename       (1L<<7)
  162. /* 3.2 backward compatibility code */
  163. #define XpmInfos       (1L<<8)
  164. #define XpmReturnInfos       XpmInfos
  165. /* end 3.2 bc */
  166. #define XpmReturnPixels       (1L<<9)
  167. #define XpmExtensions      (1L<<10)
  168. #define XpmReturnExtensions XpmExtensions
  169.  
  170. #define XpmExactColors     (1L<<11)
  171. #define XpmCloseness       (1L<<12)
  172. #define XpmRGBCloseness       (1L<<13)
  173. #define XpmColorKey       (1L<<14)
  174.  
  175. #define XpmColorTable      (1L<<15)
  176. #define XpmReturnColorTable XpmColorTable
  177.  
  178. /* XpmInfo value masks bits */
  179. #define XpmComments        XpmInfos
  180. #define XpmReturnComments  XpmComments
  181.  
  182. /* XpmAttributes mask_pixel value when there is no mask */
  183. #define XpmUndefPixel 0x80000000
  184.  
  185. /*
  186.  * color keys for visual type, they must fit along with the number key of
  187.  * each related element in xpmColorKeys[] defined in xpmP.h
  188.  */
  189. #define XPM_MONO    2
  190. #define XPM_GREY4    3
  191. #define XPM_GRAY4    3
  192. #define XPM_GREY     4
  193. #define XPM_GRAY     4
  194. #define XPM_COLOR    5
  195.  
  196.  
  197. /*
  198.  * minimal portability layer between ansi and KR C
  199.  */
  200.  
  201. /* forward declaration of functions with prototypes */
  202.  
  203. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  204.  /* ANSI || C++ */
  205. #define FUNC(f, t, p) extern t f p
  206. #define LFUNC(f, t, p) static t f p
  207. #else                    /* K&R */
  208. #define FUNC(f, t, p) extern t f()
  209. #define LFUNC(f, t, p) static t f()
  210. #endif                    /* end of K&R */
  211.  
  212.  
  213. /*
  214.  * functions declarations
  215.  */
  216.  
  217. #ifdef __cplusplus
  218. extern "C" {
  219. #endif
  220.  
  221.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  222.                     Drawable d,
  223.                     char **data,
  224.                     Pixmap *pixmap_return,
  225.                     Pixmap *shapemask_return,
  226.                     XpmAttributes *attributes));
  227.  
  228.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  229.                     char ***data_return,
  230.                     Pixmap pixmap,
  231.                     Pixmap shapemask,
  232.                     XpmAttributes *attributes));
  233.  
  234.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  235.                     Drawable d,
  236.                     char *filename,
  237.                     Pixmap *pixmap_return,
  238.                     Pixmap *shapemask_return,
  239.                     XpmAttributes *attributes));
  240.  
  241.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  242.                        char *filename,
  243.                        Pixmap pixmap,
  244.                        Pixmap shapemask,
  245.                        XpmAttributes *attributes));
  246.  
  247.     FUNC(XpmCreateImageFromData, int, (Display *display,
  248.                        char **data,
  249.                        XImage **image_return,
  250.                        XImage **shapemask_return,
  251.                        XpmAttributes *attributes));
  252.  
  253.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  254.                        char ***data_return,
  255.                        XImage *image,
  256.                        XImage *shapeimage,
  257.                        XpmAttributes *attributes));
  258.  
  259.     FUNC(XpmReadFileToImage, int, (Display *display,
  260.                    char *filename,
  261.                    XImage **image_return,
  262.                    XImage **shapeimage_return,
  263.                    XpmAttributes *attributes));
  264.  
  265.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  266.                       char *filename,
  267.                       XImage *image,
  268.                       XImage *shapeimage,
  269.                       XpmAttributes *attributes));
  270.  
  271.     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
  272.                      char *buffer,
  273.                      XImage **image_return,
  274.                      XImage **shapemask_return,
  275.                      XpmAttributes *attributes));
  276.  
  277.     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
  278.                       Drawable d,
  279.                       char *buffer,
  280.                       Pixmap *pixmap_return,
  281.                       Pixmap *shapemask_return,
  282.                       XpmAttributes *attributes));
  283.  
  284.     FUNC(XpmCreateBufferFromImage, int, (Display *display,
  285.                      char **buffer_return,
  286.                      XImage *image,
  287.                      XImage *shapeimage,
  288.                      XpmAttributes *attributes));
  289.  
  290.     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
  291.                       char **buffer_return,
  292.                       Pixmap pixmap,
  293.                       Pixmap shapemask,
  294.                       XpmAttributes *attributes));
  295.  
  296.     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
  297.     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
  298.  
  299.     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
  300.     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
  301.  
  302.     FUNC(XpmAttributesSize, int, ());
  303.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  304.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
  305.                    int nextensions));
  306.     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
  307.     FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
  308.     FUNC(XpmGetErrorString, char *, (int errcode));
  309.     FUNC(XpmLibraryVersion, int, ());
  310.  
  311.     /* XpmImage functions */
  312.     FUNC(XpmReadFileToXpmImage, int, (char *filename,
  313.                       XpmImage *image,
  314.                       XpmInfo *info));
  315.  
  316.     FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
  317.                      XpmImage *image,
  318.                      XpmInfo *info));
  319.  
  320.     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
  321.                         Drawable d,
  322.                         XpmImage *image,
  323.                         Pixmap *pixmap_return,
  324.                         Pixmap *shapemask_return,
  325.                         XpmAttributes *attributes));
  326.  
  327.     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
  328.                        XpmImage *image,
  329.                        XImage **image_return,
  330.                        XImage **shapeimage_return,
  331.                        XpmAttributes *attributes));
  332.  
  333.     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
  334.                        XImage *image,
  335.                        XImage *shapeimage,
  336.                        XpmImage *xpmimage,
  337.                        XpmAttributes *attributes));
  338.  
  339.     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
  340.                         Pixmap pixmap,
  341.                         Pixmap shapemask,
  342.                         XpmImage *xpmimage,
  343.                         XpmAttributes *attributes));
  344.  
  345.     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
  346.                       XpmImage *image,
  347.                       XpmInfo *info));
  348.  
  349.     FUNC(XpmCreateXpmImageFromData, int, (char **data,
  350.                       XpmImage *image,
  351.                       XpmInfo *info));
  352.  
  353.     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
  354.                         XpmImage *image,
  355.                         XpmInfo *info));
  356.  
  357.     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
  358.                         XpmImage *image,
  359.                         XpmInfo *info));
  360.  
  361. #ifdef __cplusplus
  362. }                    /* for C++ V2.0 */
  363. #endif
  364.  
  365.  
  366. /* backward compatibility */
  367.  
  368. /* for version 3.0c */
  369. #define XpmPixmapColorError  XpmColorError
  370. #define XpmPixmapSuccess     XpmSuccess
  371. #define XpmPixmapOpenFailed  XpmOpenFailed
  372. #define XpmPixmapFileInvalid XpmFileInvalid
  373. #define XpmPixmapNoMemory    XpmNoMemory
  374. #define XpmPixmapColorFailed XpmColorFailed
  375.  
  376. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  377.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  378. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  379.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  380.  
  381. /* for version 3.0b */
  382. #define PixmapColorError  XpmColorError
  383. #define PixmapSuccess     XpmSuccess
  384. #define PixmapOpenFailed  XpmOpenFailed
  385. #define PixmapFileInvalid XpmFileInvalid
  386. #define PixmapNoMemory    XpmNoMemory
  387. #define PixmapColorFailed XpmColorFailed
  388.  
  389. #define ColorSymbol XpmColorSymbol
  390.  
  391. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  392.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  393. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  394.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  395. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  396.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  397. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  398.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  399.  
  400. #endif /* XPM_NUMBERS */
  401. #endif
  402.